//
//  MCTopUpRecrdTableViewCell.m
//  TLYL
//
//  Created by miaocai on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCTopUpRecrdTableViewCell.h"

@interface MCTopUpRecrdTableViewCell()

@property (weak, nonatomic)  UIView *bgView;
@property (weak, nonatomic)  UILabel *moneyLabel;
@property (weak, nonatomic)  UILabel *moneyDetailLabel;
@property (weak, nonatomic)  UILabel *dateLabel;
@property (weak, nonatomic)  UILabel *dateDetailLabel;
@property (weak, nonatomic)  UILabel *statusLabel;
@property (weak, nonatomic)  UIImageView *imgV;
@end

@implementation MCTopUpRecrdTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpUI];
        self.backgroundColor = [UIColor colorWithHexString:@"#eff6fd"];
    }
    return self;
}

- (void)setUpUI{
    UIView *bgview = [[UIView alloc] init];
    [self.contentView addSubview:bgview];
    self.bgView = bgview;
    self.bgView.backgroundColor = [UIColor whiteColor];
    UILabel *moneyLabel = [[UILabel alloc] init];
    [self.contentView addSubview:moneyLabel];
    self.moneyLabel = moneyLabel;
    self.moneyLabel.text = @"充值金额：";
    self.moneyLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    self.moneyLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    UILabel *moneyDetailLabel = [[UILabel alloc] init];
    [self.contentView addSubview:moneyDetailLabel];
    self.moneyDetailLabel = moneyDetailLabel;
    self.moneyDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    self.moneyDetailLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    
    UILabel *dateLabel = [[UILabel alloc] init];
    [self.contentView addSubview:dateLabel];
    self.dateLabel = dateLabel;
    self.dateLabel.text = @"时间：";
    UILabel *dateDetailLabel = [[UILabel alloc] init];
    [self.contentView addSubview:dateDetailLabel];
    self.dateDetailLabel = dateDetailLabel;
    self.dateLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    self.dateLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    self.dateDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    self.dateDetailLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    UILabel *statusLabel = [[UILabel alloc] init];
    [self.contentView addSubview:statusLabel];
    self.statusLabel = statusLabel;
    self.statusLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    self.statusLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    self.bgView.layer.cornerRadius = 10.0f;
    self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#eff6fd"].CGColor;
    self.bgView.layer.borderWidth = 1.0f;
    
    UIImageView *imgV = [[UIImageView alloc] init];
    [self.contentView addSubview:imgV];
    self.imgV = imgV;
    self.imgV.image = [UIImage imageNamed:@"矩形-11-拷贝-3"];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(MC_REALVALUE(10));
        make.right.bottom.equalTo(self.contentView).offset(-MC_REALVALUE(10));
        make.top.equalTo(self.contentView);
    }];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(MC_REALVALUE(20));
        make.top.equalTo(self.bgView).offset(MC_REALVALUE(17));
    }];
    [self.moneyDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLabel.mas_right);
        make.top.equalTo(self.moneyLabel);
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.moneyLabel.mas_bottom).offset(MC_REALVALUE(10));
        make.left.equalTo(self.moneyLabel);
    }];
    [self.dateDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel.mas_right);
        make.top.equalTo(self.dateLabel);
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView).offset(-MC_REALVALUE(30));
        make.centerY.equalTo(self.bgView);
    }];
    [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bgView);
        make.right.equalTo(self.bgView).offset(-MC_REALVALUE(5));
        make.width.equalTo(@(MC_REALVALUE(8)));
        make.height.equalTo(@(MC_REALVALUE(14)));
        
    }];
}
- (void)setDataSource:(MCTopUpRecordModel *)dataSource{
    _dataSource = dataSource;
    
    self.dateDetailLabel.text = dataSource.CreateTime;
    self.moneyDetailLabel.text = dataSource.RechargeMoney;
    
    if ([dataSource.RechargeState isEqualToString:@"1"]) {
        self.statusLabel.text = @"交易成功";
        self.statusLabel.textColor = RGB(27, 129, 207);
    }else if ([dataSource.RechargeState isEqualToString:@"2"]){
        self.statusLabel.text = @"交易失败";
        self.statusLabel.textColor = RGB(178, 11, 25);
        
    }else if ([dataSource.RechargeState isEqualToString:@"0"]){
        self.statusLabel.text = @"未处理";
        self.statusLabel.textColor = RGB(178, 11, 25);
    }else if ([dataSource.RechargeState isEqualToString:@""]){
        

    }else{}
    
//    self.statusLabel.textColor = RGB(220, 102, 109);
    
}
@end
